package com.wangsd.web.coupon.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "coupon")
@ApiModel(value = "优惠券", description = "优惠券")
public class Coupon {

    @ApiModelProperty(value = "id")
    /*mybatis plus 自增主键*/
    @TableId(type = IdType.UUID)
    @Id
    private String id;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;

    @ApiModelProperty(value = "（逻辑删除）是否已删；0，未删，1，已删")
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Integer deleted;

    @ApiModelProperty(value = "优惠券名称")
    private String name;

    @ApiModelProperty(value = "代金券批次ID")
    private String couponStockId;

    @ApiModelProperty(value = "代金券面额")
    private Integer couponValue;

    @ApiModelProperty(value = "代金券批次状态 1-未激活；2-审批中；4-已激活；8-已作废；16-中止发放")
    private Integer couponStockStatus;

    @ApiModelProperty(value = "代金券使用最低限额")
    private Integer couponMininumn;

    @ApiModelProperty(value = "生效开始时间")
    private String beginTime;

    @ApiModelProperty(value = "生效结束时间")
    private String endTime;

    @ApiModelProperty(value = "描述")
    @Lob
    @Column(name = "note", columnDefinition = "text")
    private String note;

    @ApiModelProperty(value = "0未上架，1上架")
    @Column(name = "state", columnDefinition = "int(2) default 0 not null")
    private Integer state;

    @ApiModelProperty(value = "排序字段")
    @Column(name = "sort", columnDefinition = "int(20) default 0 not null")
    private Integer sort;

    @ApiModelProperty(value = "商圈(公司)id")
    private Long companyId;

    @ApiModelProperty(value = "1,免费优惠卷，2，购买的优惠券")
    private Integer type;

    @ApiModelProperty(value = "type 为2时价值，为3积分")
    private Integer value;

    @ApiModelProperty(value = "支付子商户id")
    private String paySubMchId;

    @ApiModelProperty(value = "优惠券图片url")
    private String couponPicUrl;

    @ApiModelProperty(value = "检索标识")
    private String code;

    @ApiModelProperty(value = "代金券总量")
    @Column(name = "coupon_total", columnDefinition = "int(20) default 0 not null")
    private Integer couponTotal;

    @ApiModelProperty(value = "代金券已经领取数量")
    @Column(name = "is_send_num", columnDefinition = "int(20) default 0 not null")
    private Integer isSendNum;

    @ApiModelProperty(value = "代金券每个人最多能领取的数量, 如果为0，则表示没有限制")
    private Integer maxQuota;

    @ApiModelProperty(value = "商圈（公司名称）")
    @Transient
    @TableField(exist = false)
    private String companyName;

    @ApiModelProperty(value = "是否有效，0未失效，1 失效")
    @Transient
    @TableField(exist = false)
    private Integer isExpired;

    @ApiModelProperty(value = "门店id List")
    @Transient
    @TableField(exist = false)
    private List<Long> storeIds;

    @ApiModelProperty(value = "门店 code list")
    @Transient
    @TableField(exist = false)
    private List<String> storeCodes;

    @ApiModelProperty(value = "openid")
    @TableField(exist = false)
    @Transient
    private String openid;

    @ApiModelProperty(value = "门店对象")
    @Transient
    @TableField(exist = false)
    private List<Store> stores;

    @ApiModelProperty(value = "商家券券id")
    @Transient
    @TableField(exist = false)
    private String couponCode;
}

